<?php 
if (isset($_GET['uid'])){
	$uid=$_GET['uid'];
}else{
	$uid=0;
}
if ($uid>0){
	require_once 'mysql_connect.php';
	$query="select file_name,file_type,file_size from uploads where upload_id=$uid";
	$result=mysql_query($query);
	list($fn,$ft,$fs)=mysql_fetch_array($result);
	mysql_close();
	
	//determine the file name on the server
	$the_file='../uploads/'.$uid;
	
	if (file_exists($the_file)){
		header("Content-Type:$ft\n");
		header("Content-disposition:attachment;filename=\"$fn\"\n");
		header("Content-Length:$fs\n");
		readfile($the_file);
	}else {
		$page_title='File Download';
		include './includes/header.html';
		echo '<p><font color="red">The File could not be located on the server</font></p>';
		include './includes/footer.html';
	}
}else{
	$page_title='File Download';
	include './includes/header.html';
	echo '<p><font color="red">please select a valid file to download.</font></p>';
	include './includes/footer.html';
}
?>